﻿
String.prototype.StringIsNullOrEmpty = function () {
    if ((this != null) && (this.length > 0))
        return false;
    else
        return true;
}

//http://www.cnblogs.com/rubylouvre/archive/2009/09/18/1568794.html
String.prototype.Trim = function () {
    var str = this,
    str = str.replace(/^\s\s*/, ''),
    ws = /\s/,
    i = str.length;
    while (ws.test(str.charAt(--i)));
    return str.slice(0, i + 1);
}

/*
　 *　方法:Array.Remove(dx)
　 *　功能:删除数组元素.
　 *　参数:dx删除元素的下标.
　 *　返回:在原数组上修改数组.
　 */

//我们也可以用splice来实现.

Array.prototype.Remove = function (dx) {
    if (isNaN(dx) || dx > this.length) { return false; }
    this.splice(dx, 1);
}

//自定义的一个字符串连接类，用于拼接字符串，比"+"要提升性能
//http://www.cnblogs.com/RascallySnake/archive/2010/07/07/1772884.html
function StringBuffer() {
    this._strs = new Array();
}
StringBuffer.prototype.append = function (str) {
    this._strs.push(str);
};
StringBuffer.prototype.arrayToString = function (spea) {
    return this._strs.join(spea);
};


//打印
function printpage(myDiv) {

    //var newstr = document.all.item(myDiv).innerHTML; 
    var newstr = document.getElementById(myDiv).innerHTML;
    //alert(newstr);
    var oldstr = document.body.innerHTML;
    document.body.innerHTML = newstr;
    window.print();
    document.body.innerHTML = oldstr;
    return false;
}

//关闭窗口
function CloseWindow()
{
    window.opener = null;
    window.open('', '_self');
    window.close();
}
